package utils;

import java.util.ArrayList;

public class StringParse {
	
	final static String AGENTSPOSITONS_DELIMITER = "#-";
	final static String OBJECTPOSITONS_DELIMITER = "#-";
	final static String COORDINATES_DELIMITER = "*";
	final static String AGENTSCOLLECTIONS_DELIMITER = ":#";
	
	public static ArrayList<String[]> parseUpdate(String agentsPositions, String objectsPositions, 
			String roomSize, String agentState, String agentCollection){
		
		ArrayList<String[]> parseResult = new ArrayList<String[]>();
		parseResult.add(parseAgentPositions(agentsPositions));
		parseResult.add(parseObjectsPositions(objectsPositions));
		parseResult.add(parseRoomSize(roomSize));
		parseResult.add(parseAgentState(agentState));
		parseResult.add(parseAgentCollection(agentCollection));
		
		return parseResult;
	}
	
	private static String[] parseAgentPositions(String agentsPositions){
		String delims_agentsPositions = "["+AGENTSPOSITONS_DELIMITER+"]";
		String[] agentPositions_array = agentsPositions.split(delims_agentsPositions);
		return agentPositions_array;
	}
	
	private static String[] parseObjectsPositions(String objectsPositions){
		String delims_objectsPositions = "["+OBJECTPOSITONS_DELIMITER+"]";
		String[] agentObjects_array = objectsPositions.split(delims_objectsPositions);
		return agentObjects_array;
	}
	
	private static String[] parseRoomSize(String roomSize){
		String delims_parseRoomSize = "["+"-"+"]";
		String[] parseRoomSize_array = roomSize.split(delims_parseRoomSize);
		return parseRoomSize_array;
	}
	
	private static String[] parseAgentState(String agentState){
		String delims_agentState = "["+COORDINATES_DELIMITER+"]";
		String[] parseAgentState_array = agentState.split(delims_agentState);
		return parseAgentState_array;
	}
	
	private static String[] parseAgentCollection(String agentCollection){
		String delims_agentCollection = "["+AGENTSCOLLECTIONS_DELIMITER+"]";
		String[] parseAgentCollection_array = agentCollection.split(delims_agentCollection);
		return parseAgentCollection_array;
	}
}
